import com.fz.entity.Student;
import com.fz.mapper.StudentMapper;
import com.fz.mybatis.MyHelper;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by webrx on 2017-08-26.
 */
public class tt {
    public static void main(String[] args) throws IOException {
       MyHelper mh=new MyHelper();
       StudentMapper ss=mh.getSession().getMapper(StudentMapper.class);

       //通过注解方式添加数据
        ss.addss("石宇航",100,"河南长葛");

       //通过map插入数据
       Map<String,Object> map=new HashMap<String,Object>();
       //键值对  前面的是列名，后面的是值
       map.put("name","shiyuhang");
       map.put("score",60);
       map.put("address","she");
       //调用add方法把值给插入到数据库
       ss.add(map);

       //通过实例化类插入数据
       Student stu=new Student();
       stu.setName("窝草尼玛了");
       stu.setScore(100);
       stu.setAddress("河南许昌长葛");
       ss.adds(stu);


        //修改数据
        ss.up("ss",27);
        //用List查询数据
//        List<Student> st=ss.query();
//        for(Student stt:st){
//            System.out.println(stt.getName());
//            System.out.println(stt.getScore());
//            System.out.println(stt.getAddress());
//        }
        //用Map 查询数据
        System.out.println(ss.se().size());
        for(Map<String,Object> mm: ss.se()){
           System.out.println(mm.get("id"));
           System.out.println(mm.get("NAME"));
           System.out.println(mm.get("score"));
           System.out.println(mm.get("address"));
       }

        ss.se();
        //ss.det(29);
        //ss.dep();
        // mh.getSession().commit();
    }
}
